package managedbean;

import entity.Account;
import entity.Item;
import entity.Wishlist;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import sessionbean.facade.AccountFacade;
import sessionbean.UpdaterSession;

@ManagedBean
@ViewScoped
public class HarvesterBean implements Serializable {
    @EJB
    private UpdaterSession harvesterSession;
    @EJB
    private AccountFacade accountFacade;
    
    private Account account;
    private List<Item> items;
    private Wishlist newWishlist = new Wishlist();
    
    @PostConstruct
    public void init() {
        setAccount(accountFacade.find(1));
    }
    
    public String addWishlist() {
        getNewWishlist().setAccount(getAccount());
        getAccount().getWishlists().add(getNewWishlist());
        accountFacade.edit(getAccount());
        return null;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public List<Item> getItems() {
        return items;
    }

    public void setItems(List<Item> items) {
        this.items = items;
    }

    public Wishlist getNewWishlist() {
        return newWishlist;
    }

    public void setNewWishlist(Wishlist newWishlist) {
        this.newWishlist = newWishlist;
    }
    
}